%julien day conversion function.
%Aaron Blake
%last modified 1/29/03
%This is in "bereau" days, ie, jan 1st at 00:00 hrs is 1.0 days
%To convert to standard jdays, add a -1 to the final expresion
function jday=julianday(year,month,day,hour,min,seconds);
%number of days in each month, [nonleap year;leap year]
numdays=[31,28,31,30,31,30,31,31,30,31,30,31 ; 31,29,31,30,31,30,31,31,30,31,30,31];
%Decide if it is leap year
if (rem(year,4)==0) & ~((rem(year,100)==0) & (rem(year,400)~=0))
    lyear=2;   % leap year
else
    lyear=1;    %not a leap year
end 
if month ==1
    monthdays=0;
else
    monthdays=sum(numdays(lyear,(1:(month-1))));
end
timedays=(hour + (min/60) + (seconds/3600))/24;
jday=monthdays+day+timedays;
 